package com.bijiawang.user.service;

import com.bijiawang.user.bean.History;
import com.bijiawang.user.mapper.HistoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;

@Service
public class HistoryService {
    @Autowired
    HistoryMapper historyMapper;

    public ArrayList<History> sele(String username){
        ArrayList<History> list;
        list = historyMapper.findXm(username);
        return list;
    }

    public History inster(History xm){
        historyMapper.inser(xm);
        return xm;
    }

    public Integer seleUrl(String url,String username){
        History sele = historyMapper.sele(url,username);
        if (sele == null) return 0;
        else return 1;
    }

    public void updateDtime(String url, String username, Date dtime){
        historyMapper.update(url, username,dtime);
    }

    public void updateUsername(String oldUsername,String newUsername){
        historyMapper.updateusername(oldUsername,newUsername);
        historyMapper.updateusername1(oldUsername,newUsername);
        historyMapper.updateusername2(oldUsername,newUsername);
    }
}
